clear all
set more off
cd D:\Dropbox\EffectPetition\JJPS\LeeKim_StataFiles\submission
cap log close
cls
//log using LeeKim_Jjps_2024_petition, text replace
log using LeeKim_Jjps_2024_petition, replace
use Dat, clear

//========================================
//
// Table 1: Summary Statistics
//
//========================================
sum Action adopt adopt1 realize realize1 sponsor_yotou inside_lobby diet_lobby outside_lobby time gov_support gov_oppose

//========================================
//
// Digression: Defining overall ATE
//
//========================================
local X ""
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store short_reg_v0
qui margins, dydx(1.adopt1) post
estimates store overall_by_margins

sum Action if realize1<999999
local Eaction = r(mean)
estimates res short_reg_v0
lincom _b[1.adopt1] + _b[1.adopt1#1.Action]*`Eaction'
estimates replay overall_by_margins

// Therefore, overall impact is calculated by margins command
// Action/NBR petition impacts are identified by beta_1 & (beta_1 + beta_3) respectively.

//========================================
//
// Table 2: Main Result
//
//========================================

local X ""
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder1
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v0

local X "i.time sponsor_yotou"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder2
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_yotou

local X "i.time inside_lobby diet_lobby outside_lobby"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder3
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_lobby

local X "i.time sponsor_yotou inside_lobby diet_lobby outside_lobby"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder4
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v1

esttab ape_if_all_v0 ape_if_act_v0 ape_if_nbr_v0 ape_if_all_yotou ape_if_act_yotou ape_if_nbr_yotou, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table2") noomit
esttab ape_if_all_lobby ape_if_act_lobby ape_if_nbr_lobby ape_if_all_v1 ape_if_act_v1 ape_if_nbr_v1, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table2") noomit
esttab place_holder1 place_holder2 place_holder3 place_holder4, keep(1.adopt1 1.Action 1.adopt1#1.Action sponsor_yotou inside_lobby diet_lobby outside_lobby) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table2") noomit

//========================================
//
// Table 3: Controlling Governor Variables
//
//========================================

local X "gov_support gov_oppose"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder1
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v0

local X "i.time sponsor_yotou gov_support gov_oppose"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder2
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_yotou

local X "i.time inside_lobby diet_lobby outside_lobby gov_support gov_oppose"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder3
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_lobby

local X "i.time sponsor_yotou inside_lobby diet_lobby outside_lobby gov_support gov_oppose"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder4
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v1

esttab ape_if_all_v0 ape_if_act_v0 ape_if_nbr_v0 ape_if_all_yotou ape_if_act_yotou ape_if_nbr_yotou, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table3") noomit
esttab ape_if_all_lobby ape_if_act_lobby ape_if_nbr_lobby ape_if_all_v1 ape_if_act_v1 ape_if_nbr_v1, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table3") noomit
esttab place_holder1 place_holder2 place_holder3 place_holder4, keep(1.adopt1 1.Action 1.adopt1#1.Action sponsor_yotou inside_lobby diet_lobby outside_lobby gov_support gov_oppose) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table3") noomit

//========================================
//
// Appendix A.1.: Further Robustness Checks
//
//========================================
preserve
drop if pid==21 | pid==139 | pid==29 | pid==116 | pid==106| pid==167| pid==172 | pid==69 | pid==102 | pid==147| pid==220 | pid==184

local X ""
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder1
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v0
estimates res place_holder1
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v0

local X "i.time sponsor_yotou"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder2
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_yotou
estimates res place_holder2
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_yotou

local X "i.time inside_lobby diet_lobby outside_lobby"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder3
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_lobby
estimates res place_holder3
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_lobby

local X "i.time sponsor_yotou inside_lobby diet_lobby outside_lobby"
qui areg realize1 i.adopt1##i.Action `X', absorb(rid) vce(r)
estimates store place_holder4
qui margins, dydx(1.adopt1) post
estimates store ape_if_all_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(1.Action==1) post
estimates store ape_if_act_v1
estimates res place_holder4
qui margins, dydx(1.adopt1) at(0.Action==1) post
estimates store ape_if_nbr_v1

esttab ape_if_all_v0 ape_if_act_v0 ape_if_nbr_v0 ape_if_all_yotou ape_if_act_yotou ape_if_nbr_yotou, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table.A.1.") noomit
esttab ape_if_all_lobby ape_if_act_lobby ape_if_nbr_lobby ape_if_all_v1 ape_if_act_v1 ape_if_nbr_v1, keep(1.adopt1) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table.A.1.") noomit
esttab place_holder1 place_holder2 place_holder3 place_holder4, keep(1.adopt1 1.Action 1.adopt1#1.Action sponsor_yotou inside_lobby diet_lobby outside_lobby) b(%8.3f) se(%8.3f) scalars(N) r2(%8.2f) star(* .1 ** .05 *** .01) mtitles title("Table.A.1.") noomit

restore




cap log close